package com.ruoyi.hotel.domain.converter;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.hotel.domain.Room;
import com.ruoyi.hotel.domain.from.RoomFrom;
import com.ruoyi.hotel.domain.vo.RoomVo;


import java.util.ArrayList;
import java.util.List;

public class RoomConverter {
    public static Room converterToPoByFrom(RoomFrom source){
        if (source == null) {
            return null;
        }
        Room target = new Room();
        BeanUtil.copyProperties(source, target);
        return target;

    }

    public static List<Room> converterToPoByFrom(List<RoomFrom> sources){
        if (CollUtil.isEmpty(sources)) {
            return null;
        }
        List<Room> result=new ArrayList<>();
        for(RoomFrom source: sources){
            Room target = new Room();
            BeanUtil.copyProperties(source, target);
            result.add(target);
        }
        return result;

    }


    public static List<RoomVo> converterToVoByPo(List<Room> sources){
        if (CollUtil.isEmpty(sources)) {
            return null;
        }
        List<RoomVo> result=new ArrayList<>();
        for(Room source: sources){
            RoomVo target = new RoomVo();
            BeanUtil.copyProperties(source, target);
            result.add(target);
        }
        return result;

    }
}
